
class ReviewUtils:
    @staticmethod
    def get_reviews_fromdto(nlp_analyse_request):
        reviews_list = ReviewUtils.get_all_reviews_fromlist(nlp_analyse_request.get('reviews'))
        print("计算的评论数：", len(reviews_list))

        return reviews_list

    @staticmethod
    def get_reviews_fromESREsult(reviews_es_data):
        reviews_results = []
        reviews_contents = []

        reviews_es_results = reviews_es_data.get('result')
        for review_es_result in reviews_es_results:
            reviews_results.append(review_es_result["_source"])
            #reviews_contents.append({"review_id":review_es_result["_source"]["id"],"content":review_es_result["_source"]["content"]})
            #reviews_contents.append(review_es_result["_source"]["content"])
            reviews_contents.append({"id":review_es_result["_source"]["id"],"content":review_es_result["_source"]["content"]})

        print("计算的评论数：", len(reviews_results))

        return reviews_results,reviews_contents

    @staticmethod
    def get_all_reviews_fromlist(reviews):
        all_reviews = []
        for review in reviews:
            all_reviews.append(review.get('text'))
        return all_reviews